package com.charging.controller;


import com.charging.config.config.BaseController;
import com.charging.config.result.ApiResult;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

/**
 * <p>
 * 后台用户表 前端控制器
 * </p>
 *
 * @author 冯政尚
 * @since 2019-09-12
 */
@Controller
@RequestMapping("admin/userInfo")
public class UserInfoController extends BaseController {

    /**
     * @return 跳转登陆页面
     */
    @RequestMapping(value = "login.html",method = RequestMethod.GET)
    public String login(){
        return "login";
    }


    @RequestMapping(value = "a.html",method = RequestMethod.GET)
    public String a(){
        return "a";
    }
    /**
     * @return 跳转首页页面
     */
    @RequestMapping(value = "index.html",method = RequestMethod.GET)
    public String index(){
        return "index";
    }
    /**
     * @return 跳转欢迎页面
     */
    @RequestMapping(value = "welcome.html",method = RequestMethod.GET)
    public String welcome(){
        return "welcome";
    }


    //登陆
    @RequestMapping(value = "/login")
    @ResponseBody
    public ApiResult login(HttpSession session, String account, String password) {
        if(userInfoService.login(account,password,session)){
            return ApiResult.ok();
        }
        return ApiResult.fail("账户或密码错误");
    }

}
